package hr.ctg.domain.model;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Immutable;

@Entity
@Table(name = "tip_objave")
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
@Immutable
public class TipObjave implements Serializable {
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id_tipa_objave")
	private int idTipaObjave;

	private String naziv;

	@OneToMany(mappedBy = "tipObjave")
	private Set<Objava> objavaCollection;

	private static final long serialVersionUID = 1L;

	public TipObjave() {
		super();
	}

	public int getIdTipaObjave() {
		return idTipaObjave;
	}

	public void setIdTipaObjave(final int idTipaObjave) {
		this.idTipaObjave = idTipaObjave;
	}

	public String getNaziv() {
		return naziv;
	}

	public void setNaziv(final String naziv) {
		this.naziv = naziv;
	}

	public Set<Objava> getObjavaCollection() {
		return objavaCollection;
	}

	public void setObjavaCollection(final Set<Objava> objavaCollection) {
		this.objavaCollection = objavaCollection;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + idTipaObjave;
		return result;
	}

	@Override
	public boolean equals(final Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		final TipObjave other = (TipObjave) obj;
		if (idTipaObjave != other.idTipaObjave) {
			return false;
		}
		return true;
	}

}
